#include <bits/stdc++.h>
#define rep(i,l,r) for (int i = l; i <= r; i ++)
#define per(i,r,l) for (int i = r; i >= l; i --)
using namespace std;
const int M = 2e5 + 5;
int N,S,T,Seq[M],Size[M],id[M],Link[M],Block[M],Temp[M],Fir[M],Ed[M],k;
int main () {
	freopen ("fruit.in","r",stdin);
	freopen ("fruit.out","w",stdout);
	scanf ("%d",&N);
	Seq[0] = - 1;
	rep (i,1,N) {
		scanf ("%d",&Seq[i]);
		if (Seq[i] != Seq[i - 1]) Block[++ S] = S,id[S] = Seq[i],Fir[S] = i;
		else ++ Size[S],Ed[S - 1] = i,Link[i - 1] = i;
	}
	Link[N] = - 1;
	while (S > 0) {
		T = 0;
		k ++;
		rep (i,1,S) {
			printf ("%d ",Fir[i]);
			Size[i] --,Fir[i] = Link[Fir[i]];
            
		}cout << '\n';
		for (int i = 1; i <= S ; i ++) {
			if (Size[i] >= 0) Temp [++ T] = i;
		}
		rep (i,1,T) Size[i] = Size[Temp[i]],Fir[i] = Fir[Temp[i]],Ed[i] = Ed[Fir[Temp[i]]];
		S = T;
	} 
	return 0;
}

